package cn.itsource.system.service.impl;
import cn.itsource.system.domain.Log;
import cn.itsource.system.mapper.LogMapper;
import cn.itsource.system.query.LogQuery;
import cn.itsource.system.service.ILogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
public class LogServiceImpl implements ILogService {
    @Autowired(required = false)
    private LogMapper logMapper;
    @Override
    public List<Log> findAll() {
        return logMapper.findAll();
    }

    @Override
    public Log findOne(Long id) {
        return logMapper.findOne(id);
    }

    @Override
    public void add(Log log) {
        logMapper.add(log);
    }

    @Override
    @Transactional

    public void del(Long id) {
        logMapper.del(id);
    }

    @Override
    @Transactional

    public void update(Log log) {
        logMapper.update(log);
    }

    @Override
    @Transactional

    public void patchDel(Long[] ids) {
        logMapper.patchDel(ids);
    }

    @Override
    public PageInfo<Log> queryPage(LogQuery logQuery) {
        PageHelper.startPage(logQuery.getCurrentPage(),logQuery.getPageSize());
        List<Log> logList = logMapper.queryPage(logQuery);
        PageInfo<Log> pageInfo = new PageInfo<>(logList);
        return pageInfo;
    }
}
